package com.winchain.chainbill.bill.biz.send.cmd;

import com.shell.framework.command.CommandContext;
import com.shell.framework.command.ICommand;
import com.winchain.chainbill.basic.context.TimeoutOperation;
import com.winchain.chainbill.bill.base.po.CbOpt;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.send.service.BillTimeoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillTimeoutCmd<T> implements ICommand<Bill<T>> {
	@Autowired
	private BillTimeoutService billTimeoutService;

	public boolean execute(CommandContext<Bill<T>> context) throws Exception {
		boolean timeout = this.billTimeoutService.check(((Bill) context.getSource()).getRec(),
				(CbOpt) context.getValue("Operation"), (TimeoutOperation) context.getValue("TimeoutOperation"));

		context.setValue("Timeout", Boolean.valueOf(timeout));
		return false;
	}
}
